<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>测试Object.defineproperty()</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
    <div id="app">
        <input type="text" id="in">
        <span>view:</span><span id="sp"></span>
    
    </div>

    <script>
        
        var obj = {};
        Object.defineProperty(obj,'hello',{
            get:function(){
                console.log('get val:' + value);
                return value;
            },
            set:function(newVal){
                value = newVal;
                console.log('set val:' + value);
                document.getElementById('in').value = value;
                document.getElementById('sp').innerHTML = value;
            }
        });
        
        document.addEventListener('keyup',function(e){
            console.log(e.target)
            obj.hello = e.target.value;
        })
        
        var num = 123;
        var str = 'string';
        var bool = true;
        var nul = null;
        var un = undefined;
        var arr = [];
        var obj = {};
        function fun(){};

        console.log('num',typeof num);
        console.log('str',typeof str); 
        console.log('bool',typeof bool); 
        console.log('nul',typeof nul); 
        console.log('un',typeof un); 
        console.log('arr',typeof arr); 
        console.log('obj',typeof obj); 
        console.log('fun',typeof fun); 

        var num1 = 1.4;
        var num2 = '123a';
        console.log(typeof parseInt(num1),parseInt(num2))

    </script>
</body>
</html>